package com.arthur.controller;

import com.arthur.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@Controller
public class DeleteCartinfoController {
    @Autowired
    @Qualifier("userService")
    private UserService userService;
    @RequestMapping("/DeleteCartinfoController")
    @ResponseBody
    protected Map deleteCartinfo(HttpServletRequest request)throws Exception{
        Map<String, Object> objectMap = new HashMap<>();
        try {
            int id = Integer.parseInt(request.getParameter("id"));
            int rows = userService.deleteCartinfoById(id);
            if (rows == 1) {
                objectMap.put("result", "1");
            } else {
                objectMap.put("result", "0");
            }
        } catch (Exception e) {
            objectMap.put("result", "0");
            e.printStackTrace();
        }
        return objectMap;
    }
}
